using DukeyTbker.Properties;
using ns1;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;

public class WebPublishOptionFrm : Form
{
    private Button btnTestConnect;
    private Button button1;
    private GroupBox groupBox1;
    private GroupBox groupBox2;
    private IContainer icontainer_0;
    private Label label1;
    private Label label2;
    private Label label3;
    private Label label4;
    private Label label5;
    private Label label6;
    private Label lblTipChannel;
    private List<Channel> list_0 = new List<Channel>();
    private ListBox listBox1;
    private ListBox listBox2;
    private ListBox listBox3;
    [CompilerGenerated]
    private static Predicate<Channel> predicate_0;
    [CompilerGenerated]
    private static Predicate<Channel> predicate_1;
    private SoftCaiJIAPI softCaiJIAPI_0 = new SoftCaiJIAPI();
    private tbproductasmx[] tbproductasmx_0;
    private TextBox txtChannelID;
    private TextBox txtPostUrl;
    private TextBox txtRSAkey;

    public WebPublishOptionFrm(tbproductasmx[] tbproductasmx_1)
    {
        this.InitializeComponent();
        this.tbproductasmx_0 = tbproductasmx_1;
        try
        {
            this.txtPostUrl.Text = Settings.Default.PostUrl;
            this.txtRSAkey.Text = Settings.Default.RSAKey;
        }
        catch
        {
        }
    }

    private void btnTestConnect_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(this.txtPostUrl.Text.Trim()))
        {
            MessageBox.Show("接口地址不能为空!");
        }
        else
        {
            this.softCaiJIAPI_0.Url = this.txtPostUrl.Text.Trim();
            try
            {
                this.btnTestConnect.Enabled = false;
                this.list_0.Clear();
                string rSAKey = this.txtRSAkey.Text.Trim();
                foreach (Channel channel in this.softCaiJIAPI_0.GetChannel(rSAKey))
                {
                    this.list_0.Add(channel);
                }
                this.listBox1.DisplayMember = "cname";
                this.listBox1.ValueMember = "bid";
                if (predicate_1 == null)
                {
                    predicate_1 = new Predicate<Channel>(WebPublishOptionFrm.smethod_1);
                }
                this.listBox1.DataSource = this.list_0.FindAll(predicate_1);
                MessageBox.Show("连接成功!");
                Settings.Default.PostUrl = this.softCaiJIAPI_0.Url;
                Settings.Default.RSAKey = this.txtRSAkey.Text.Trim();
                Settings.Default.Save();
                this.btnTestConnect.Enabled = true;
            }
            catch (Exception)
            {
                MessageBox.Show("连接不成功!请检查接口地址和密文设置是否正确!");
                this.btnTestConnect.Enabled = true;
            }
        }
    }

    private void button1_Click(object sender, EventArgs e)
    {
        try
        {
            this.button1.Enabled = false;
            if (string.IsNullOrEmpty(this.txtChannelID.Text))
            {
                MessageBox.Show("你还没选择发布到哪个栏目喔^_^!");
                this.button1.Enabled = true;
            }
            else
            {
                string rSAKey = this.txtRSAkey.Text.Trim();
                if (this.softCaiJIAPI_0.PublishCaiji(this.tbproductasmx_0, this.txtChannelID.Text, rSAKey) == "empty")
                {
                    MessageBox.Show("没有获取到数据！");
                    this.button1.Enabled = true;
                    base.DialogResult = DialogResult.Cancel;
                }
                else
                {
                    this.button1.Enabled = true;
                    base.DialogResult = DialogResult.OK;
                }
            }
        }
        catch (Exception exception)
        {
            this.button1.Enabled = true;
            MessageBox.Show(exception.Message);
        }
    }

    protected override void Dispose(bool disposing)
    {
        if (disposing && (this.icontainer_0 != null))
        {
            this.icontainer_0.Dispose();
        }
        base.Dispose(disposing);
    }

    private void InitializeComponent()
    {
        this.groupBox1 = new GroupBox();
        this.label2 = new Label();
        this.label1 = new Label();
        this.txtRSAkey = new TextBox();
        this.txtPostUrl = new TextBox();
        this.button1 = new Button();
        this.label3 = new Label();
        this.groupBox2 = new GroupBox();
        this.txtChannelID = new TextBox();
        this.lblTipChannel = new Label();
        this.listBox3 = new ListBox();
        this.listBox2 = new ListBox();
        this.listBox1 = new ListBox();
        this.label6 = new Label();
        this.label5 = new Label();
        this.label4 = new Label();
        this.btnTestConnect = new Button();
        this.groupBox1.SuspendLayout();
        this.groupBox2.SuspendLayout();
        base.SuspendLayout();
        this.groupBox1.Controls.Add(this.btnTestConnect);
        this.groupBox1.Controls.Add(this.label2);
        this.groupBox1.Controls.Add(this.label1);
        this.groupBox1.Controls.Add(this.txtRSAkey);
        this.groupBox1.Controls.Add(this.txtPostUrl);
        this.groupBox1.Location = new Point(0x15, 12);
        this.groupBox1.Name = "groupBox1";
        this.groupBox1.Size = new Size(0x1d5, 0x59);
        this.groupBox1.TabIndex = 0;
        this.groupBox1.TabStop = false;
        this.groupBox1.Text = "设置";
        this.label2.AutoSize = true;
        this.label2.Location = new Point(30, 0x39);
        this.label2.Name = "label2";
        this.label2.Size = new Size(0x23, 12);
        this.label2.TabIndex = 1;
        this.label2.Text = "密文:";
        this.label1.AutoSize = true;
        this.label1.Location = new Point(6, 0x1d);
        this.label1.Name = "label1";
        this.label1.Size = new Size(0x3b, 12);
        this.label1.TabIndex = 1;
        this.label1.Text = "接口地址:";
        this.txtRSAkey.Location = new Point(0x51, 0x30);
        this.txtRSAkey.Name = "txtRSAkey";
        this.txtRSAkey.Size = new Size(0xee, 0x15);
        this.txtRSAkey.TabIndex = 0;
        this.txtPostUrl.Location = new Point(0x51, 20);
        this.txtPostUrl.Name = "txtPostUrl";
        this.txtPostUrl.Size = new Size(0x166, 0x15);
        this.txtPostUrl.TabIndex = 0;
        this.button1.Location = new Point(0x19f, 0x13c);
        this.button1.Name = "button1";
        this.button1.Size = new Size(0x4b, 0x17);
        this.button1.TabIndex = 1;
        this.button1.Text = "发布";
        this.button1.UseVisualStyleBackColor = true;
        this.button1.Click += new EventHandler(this.button1_Click);
        this.label3.AutoSize = true;
        this.label3.ForeColor = Color.Red;
        this.label3.Location = new Point(0x18, 320);
        this.label3.Name = "label3";
        this.label3.Size = new Size(0x9b, 12);
        this.label3.TabIndex = 3;
        this.label3.Text = "欢迎使用都客网站发布接口!";
        this.groupBox2.Controls.Add(this.txtChannelID);
        this.groupBox2.Controls.Add(this.lblTipChannel);
        this.groupBox2.Controls.Add(this.listBox3);
        this.groupBox2.Controls.Add(this.listBox2);
        this.groupBox2.Controls.Add(this.listBox1);
        this.groupBox2.Controls.Add(this.label6);
        this.groupBox2.Controls.Add(this.label5);
        this.groupBox2.Controls.Add(this.label4);
        this.groupBox2.Location = new Point(0x15, 0x79);
        this.groupBox2.Name = "groupBox2";
        this.groupBox2.Size = new Size(0x1d5, 0xb9);
        this.groupBox2.TabIndex = 4;
        this.groupBox2.TabStop = false;
        this.groupBox2.Text = "选择栏目";
        this.txtChannelID.Location = new Point(0x1a6, 20);
        this.txtChannelID.Name = "txtChannelID";
        this.txtChannelID.Size = new Size(0x29, 0x15);
        this.txtChannelID.TabIndex = 6;
        this.txtChannelID.Visible = false;
        this.lblTipChannel.AutoSize = true;
        this.lblTipChannel.ForeColor = Color.Red;
        this.lblTipChannel.Location = new Point(0x51, 12);
        this.lblTipChannel.Name = "lblTipChannel";
        this.lblTipChannel.Size = new Size(0, 12);
        this.lblTipChannel.TabIndex = 5;
        this.listBox3.FormattingEnabled = true;
        this.listBox3.ItemHeight = 12;
        this.listBox3.Location = new Point(310, 0x34);
        this.listBox3.Name = "listBox3";
        this.listBox3.Size = new Size(120, 0x70);
        this.listBox3.TabIndex = 4;
        this.listBox3.SelectedIndexChanged += new EventHandler(this.listBox3_SelectedIndexChanged);
        this.listBox2.FormattingEnabled = true;
        this.listBox2.ItemHeight = 12;
        this.listBox2.Location = new Point(0xa9, 0x34);
        this.listBox2.Name = "listBox2";
        this.listBox2.Size = new Size(120, 0x70);
        this.listBox2.TabIndex = 4;
        this.listBox2.SelectedIndexChanged += new EventHandler(this.listBox2_SelectedIndexChanged);
        this.listBox1.FormattingEnabled = true;
        this.listBox1.ItemHeight = 12;
        this.listBox1.Location = new Point(0x1c, 0x34);
        this.listBox1.Name = "listBox1";
        this.listBox1.Size = new Size(120, 0x70);
        this.listBox1.TabIndex = 4;
        this.listBox1.SelectedIndexChanged += new EventHandler(this.listBox1_SelectedIndexChanged);
        this.label6.AutoSize = true;
        this.label6.Location = new Point(0x137, 0x25);
        this.label6.Name = "label6";
        this.label6.Size = new Size(0x35, 12);
        this.label6.TabIndex = 3;
        this.label6.Text = "三级栏目";
        this.label5.AutoSize = true;
        this.label5.Location = new Point(0xa9, 0x25);
        this.label5.Name = "label5";
        this.label5.Size = new Size(0x35, 12);
        this.label5.TabIndex = 3;
        this.label5.Text = "二级栏目";
        this.label4.AutoSize = true;
        this.label4.Location = new Point(0x19, 0x25);
        this.label4.Name = "label4";
        this.label4.Size = new Size(0x35, 12);
        this.label4.TabIndex = 3;
        this.label4.Text = "一级栏目";
        this.btnTestConnect.Location = new Point(0x16c, 0x30);
        this.btnTestConnect.Name = "btnTestConnect";
        this.btnTestConnect.Size = new Size(0x4b, 0x17);
        this.btnTestConnect.TabIndex = 5;
        this.btnTestConnect.Text = "测试连接";
        this.btnTestConnect.UseVisualStyleBackColor = true;
        this.btnTestConnect.Click += new EventHandler(this.btnTestConnect_Click);
        base.AutoScaleDimensions = new SizeF(6f, 12f);
        //base.AutoScaleMode = AutoScaleMode.Font;
        base.ClientSize = new Size(0x20d, 0x15b);
        base.Controls.Add(this.label3);
        base.Controls.Add(this.groupBox1);
        base.Controls.Add(this.groupBox2);
        base.Controls.Add(this.button1);
        base.MaximizeBox = false;
        base.MinimizeBox = false;
        base.Name = "WebPublishOptionFrm";
        base.ShowIcon = false;
        base.ShowInTaskbar = false;
        base.StartPosition = FormStartPosition.CenterScreen;
        this.Text = "网站发布接口设置 www.mou18.com";
        base.Load += new EventHandler(this.WebPublishOptionFrm_Load);
        this.groupBox1.ResumeLayout(false);
        this.groupBox1.PerformLayout();
        this.groupBox2.ResumeLayout(false);
        this.groupBox2.PerformLayout();
        base.ResumeLayout(false);
        base.PerformLayout();
    }

    private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Predicate<Channel> match = null;
        this.listBox3.DataSource = null;
        this.listBox3.Items.Clear();
        if ((this.listBox1.SelectedValue != null) && (this.listBox1.SelectedValue.ToString() != ""))
        {
            if (match == null)
            {
                match = new Predicate<Channel>(this.method_0);
            }
            this.listBox2.DataSource = this.list_0.FindAll(match);
            this.listBox2.DisplayMember = "cname";
            this.listBox2.ValueMember = "bid";
        }
        this.lblTipChannel.Text = "当前选择:" + this.listBox1.Text;
        this.txtChannelID.Text = this.listBox1.SelectedValue.ToString();
    }

    private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
    {
        Predicate<Channel> match = null;
        if ((this.listBox2.SelectedValue != null) && (this.listBox2.SelectedValue.ToString() != ""))
        {
            if (match == null)
            {
                match = new Predicate<Channel>(this.method_1);
            }
            this.listBox3.DataSource = this.list_0.FindAll(match);
            this.listBox3.DisplayMember = "cname";
            this.listBox3.ValueMember = "bid";
        }
        this.lblTipChannel.Text = "当前选择:" + this.listBox2.Text;
        this.txtChannelID.Text = this.listBox2.SelectedValue.ToString();
    }

    private void listBox3_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            this.lblTipChannel.Text = "当前选择:" + this.listBox3.Text;
            this.txtChannelID.Text = this.listBox3.SelectedValue.ToString();
        }
        catch
        {
        }
    }

    [CompilerGenerated]
    private bool method_0(Channel channel_0)
    {
        return (channel_0.Int32_1 == ((int) this.listBox1.SelectedValue));
    }

    [CompilerGenerated]
    private bool method_1(Channel channel_0)
    {
        return (channel_0.Int32_1 == ((int) this.listBox2.SelectedValue));
    }

    [CompilerGenerated]
    private static bool smethod_0(Channel channel_0)
    {
        return (channel_0.Int32_1 == 0);
    }

    [CompilerGenerated]
    private static bool smethod_1(Channel channel_0)
    {
        return (channel_0.Int32_1 == 0);
    }

    private void WebPublishOptionFrm_Load(object sender, EventArgs e)
    {
        if (this.txtPostUrl.Text.Trim() != "")
        {
            try
            {
                this.softCaiJIAPI_0.Url = this.txtPostUrl.Text.Trim();
                this.list_0.Clear();
                string rSAKey = this.txtRSAkey.Text.Trim();
                foreach (Channel channel in this.softCaiJIAPI_0.GetChannel(rSAKey))
                {
                    this.list_0.Add(channel);
                }
                this.listBox1.DisplayMember = "cname";
                this.listBox1.ValueMember = "bid";
                if (predicate_0 == null)
                {
                    predicate_0 = new Predicate<Channel>(WebPublishOptionFrm.smethod_0);
                }
                this.listBox1.DataSource = this.list_0.FindAll(predicate_0);
            }
            catch
            {
                MessageBox.Show("连接远程网站不成功!");
            }
        }
    }
}

